var e = require;
var t = module;
var o = exports;
var n;
function i(e, t) {
    return (i =
        Object.setPrototypeOf ||
        function (e, t) {
            return (e.__proto__ = t), e;
        })(e, t);
}
(o.__esModule = !0), (o.default = void 0);
var a = (function (e) {
    var t, o;
    function n() {
        return e.call(this) || this;
    }
    (o = e), ((t = n).prototype = Object.create(o.prototype)), (t.prototype.constructor = t), i(t, o);
    var a = n.prototype;
    return (
        (a.init = function () {
            (this.env = window.qg),
                (this.info = (window.lplatform && lplatform.systemInfo) || this.env.getSystemInfoSync()),
                (this.bh = lplatform.cparam.bannerHeight || 170),
                (this.bw = lplatform.cparam.bannerWidth || Math.min(this.info.windowWidth, (16 * this.bh) / 9)),
                this.env.setKeepScreenOn &&
                    this.env.setKeepScreenOn({
                        keepScreenOn: !0,
                        success: function success() {
                            console.log("handling success");
                        },
                        fail: function fail(e, t) {
                            console.log("handling fail, code = " + t);
                        }
                    });
        }),
        (a.initAD = function () {
            lplatform.plog("PHuaWei constructor initAD"),
                qg.setUnderAgeOfPromise(!1),
                qg.setNonPersonalizedAd(!1),
                this.createRewardedVideo(!1);
        }),
        (a.loadBanner = function () {
            this.hideBanner(!1),
                this.bannerAd ||
                    ((this.btop = 0),
                    lplatform.cparam.bannerOnBottom && (this.btop = this.info.windowHeight - this.bh),
                    lplatform.plog("loadBanner this.bh:" + this.bh + " this.btop:" + this.btop + " this.bw:" + this.bw),
                    (this.bannerAd = this.env.createBannerAd({
                        adUnitId: lplatform.cparam.bannerID,
                        adIntervals: 60,
                        style: {width: this.bw, height: this.bh, left: 0, top: 720}
                    })),
                    this.bannerAd.onError(function (e) {
                        console.log("bannerAd 广告加载出错", e);
                    }),
                    this.bannerAd.onLoad(function () {
                        console.log("bannerAd 广告加载成功");
                    }),
                    this.bannerAd.onClose(function () {
                        console.log("bannerAd 广告关闭");
                    })),
                this.bannerAd.show();
        }),
        (a.showBanner = function () {
            this.hideBanner(), lplatform.labData.mainSwitch && this.loadBanner(!0);
        }),
        (a.hideBanner = function (e) {
            void 0 === e && (e = !1),
                this.bannerAd &&
                    (this.bannerAd.hide(),
                    e &&
                        (this.bannerAd.offLoad(this.onBannerLoad),
                        this.bannerAd.offError(this.onBannerError),
                        this.bannerAd.offResize(this.onBannerResize),
                        this.bannerAd.destroy(),
                        (this.bannerAd = null))),
                this.moreGameBanner && this.moreGameBanner.hide();
        }),
        (a.loadInterstitial = function () {
            var e = this;
            this.createMoreGamePortal(!1, !0),
                lplatform.plog("createNativeAd lplatform.cparam.nativeID:" + lplatform.cparam.nativeID);
            var t = lplatform.cparam.nativeID;
            (this.yuanshengIndex += 1), this.yuanshengIndex >= t.length && (this.yuanshengIndex = 0);
            var o = qg.createNativeAd({
                adUnitId: t[this.yuanshengIndex],
                success: function success(e) {
                    console.log("loadNativeAd loadNativeAd : success " + e);
                },
                fail: function fail(e, t) {
                    console.log("loadNativeAd loadNativeAd fail: " + e + "," + t);
                },
                complete: function complete() {
                    o.load();
                }
            });
            o.onLoad(
                function (t) {
                    lplatform.plog("nativeAd.onLoad:" + JSON.stringify(t)),
                        o.reportAdShow({adId: t.adList[0].adId}),
                        e.yuanshengADK &&
                            (lplatform.plog("this.yuanshengADK.destroy:" + e.yuanshengADK.destroy),
                            e.yuanshengADK.destroy()),
                        (e.yuanshengADK = lplatform.uiEngine.createChaping(
                            t.adList[0],
                            function () {
                                e.yuanshengADK = null;
                            }.bind(e),
                            function () {
                                o.reportAdClick({adId: t.adList[0].adId}), (e.yuanshengADK = null);
                            }.bind(e)
                        )),
                        qg.onShow(function (n) {
                            console.log(
                                "lyn qg.onShow:" +
                                    JSON.stringify(n) +
                                    " nativeAd:" +
                                    o +
                                    " ts.yuanshengADK:" +
                                    e.yuanshengADK
                            ),
                                o &&
                                    e.yuanshengADK &&
                                    (console.log("qg.onShow reportAdShow:" + t.adList[0].adId),
                                    o.reportAdShow({adId: t.adList[0].adId}));
                        }),
                        qg.onHide(function () {});
                }.bind(e)
            ),
                o.onError(
                    function (t) {
                        console.log("nativeAd.onError:" + JSON.stringify(t)), e.showBanner();
                    }.bind(this)
                );
        }),
        (a.createRewardedVideo = function (e) {
            var t = this;
            if (lplatform.cparam.rewardedVideoID) {
                var o = this;
                this.rewardedVideoAd ||
                    "function" != typeof this.env.createRewardedVideoAd ||
                    ((this.rewardedVideoAd = this.env.createRewardedVideoAd({
                        adUnitId: lplatform.cparam.rewardedVideoID,
                        success: function success() {},
                        fail: function fail(e, t) {
                            console.log("loadAndShowVideoAd createRewardedVideoAd fail: " + e + "," + t),
                                o.onRewardedVideoError &&
                                    o.onRewardedVideoError(
                                        {msg: "createRewardedVideoAd fail"},
                                        "createRewardedVideoAd fail"
                                    );
                        },
                        complete: function complete() {
                            o.rewardedVideoAd.load(), e && t.showRewardedVideo(window.vcb);
                        }
                    })),
                    this.rewardedVideoAd.onError(this.onRewardedVideoError.bind(this)),
                    this.rewardedVideoAd.onClose(this.onRewardedVideoClose.bind(this)),
                    this.rewardedVideoAd.onLoad(this.onRewardedVideoLoad.bind(this)));
            }
        }),
        (a.canRecord = function () {
            return (
                !(!this.gameRecorderManager || !lplatform.cparam.canRecord) ||
                (lplatform.plog("huaWei,不支持录制游戏画面"), !1)
            );
        }),
        (a.shareAppMessage = function () {
            qg.serviceShare({
                shareType: 0,
                title: lplatform.cparam.shareAppTitle,
                summary: lplatform.cparam.shareAppTitle,
                imagePath: lplatform.cparam.shareAppImgUrl,
                targetUrl: lplatform.cparam.shareAppImgUrl,
                mediaUrl: lplatform.cparam.shareAppImgUrl,
                platforms: "",
                fail: function fail(e, t) {
                    console.log("service share fail:" + t + e);
                },
                cancel: function cancel() {
                    console.log("cancel");
                }
            });
        }),
        (a.makeShareUI = function (e, t, o, n, i) {
            void 0 === n && (n = 0),
                void 0 === i && (i = !1),
                lplatform.uiEngine.CreateShareK(
                    function () {
                        this.shareRecord(e, t);
                    }.bind(this),
                    function () {
                        t && t(), this.gameRecordShareBtn && this.gameRecordShareBtn.hide();
                    }.bind(this),
                    o,
                    n,
                    i
                );
        }),
        (a.shareRecord = function () {
            this.shareAppMessage(null);
        }),
        (a.createMoreGameButton = function () {}),
        (a.createMoreGameBanner = function () {}),
        (a.createMoreGamePortal = function () {}),
        (a.goToGameOrGameList = function () {
            lplatform.plog("huaWei未实现 goToGameOrGameList");
        }),
        n
    );
})(((n = e("POppo")) && n.__esModule ? n : {default: n}).default);
(o.default = a), (t.exports = o.default);
